package cn.codeforfun.config;

import javax.servlet.http.HttpSession;
import javax.websocket.HandshakeResponse;
import javax.websocket.server.HandshakeRequest;
import javax.websocket.server.ServerEndpointConfig;

/**
 * Package cn.codeforfun.config
 * Project cloud-websocket
 * Author WangBin
 * Email bin.wang12@pactera.com
 * Created on 2017/8/14 0014 17:50
 * version 1.0.0
 */
public class GetHttpSessionConfigurator extends ServerEndpointConfig.Configurator {

  @Override
  public void modifyHandshake(ServerEndpointConfig sec,
                              HandshakeRequest request, HandshakeResponse response) {
    // TODO Auto-generated method stub
    HttpSession httpSession = (HttpSession) request.getHttpSession();
    sec.getUserProperties().put(HttpSession.class.getName(), httpSession);
  }

}
